package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author whx
 * @since 2024-12-03
 */
@RestController
@RequestMapping("/questions")
@Api(tags = "问题相关接口")
public class InteractionQuestionController {

    @Autowired
    private IInteractionQuestionService interactionQuestionService;

    @PostMapping
    @ApiOperation("新增问题")
    public void addQuestion(@RequestBody QuestionFormDTO dto){
        interactionQuestionService.addQuestion(dto);
    }

    @GetMapping("/page")
    @ApiOperation("用户端分页查询问题")
    public PageDTO<QuestionVO> pageQuestion(QuestionPageQuery questionPageQuery){
        return interactionQuestionService.pageQuestion(questionPageQuery);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查看问题详情")
    public QuestionVO getById(@PathVariable Long id){
        return interactionQuestionService.getQuestionById(id);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改问题")
    public void updateById(@PathVariable Long id, @RequestBody QuestionFormDTO dto){
        interactionQuestionService.updateQuestionById(id, dto);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除问题")
    public void deleteById(@PathVariable Long id){
        interactionQuestionService.deleteById(id);
    }



}
